package com.mastercard.labs

import java.util.Date;
import java.util.List;

class User {
	
	public enum Status {ACTIVE,LOCKED,INACTIVE,PENDING_EMAIL_ACTIVICATION,PENDING_PHONE_ACTIVATION}
	public enum Gender {Male, Female}
	
    String username
    String passwordHash
	String name
	String nric
	String gender
	String mobile
	String phone
	String email
	boolean smsNotification
	boolean emailNotification
	Status status
	Date birthDate
	Date dateCreated
	Date loginDate
		
    static hasMany = [ roles: Role, permissions: String]
    static constraints = {
        username(nullable: false, blank: false, unique: true, maxSize: 20)
		passwordHash nullable: false
		loginDate nullable: true
		birthDate nullable: true
		mobile nullable: true, size: 8..20, matches: '^(\\+)?\\d{8,20}$'
		phone nullable: true, size: 8..20, matches: '^(\\+)?\\d{8,20}$'
		email nullable: true, email: true, unique: true
		name nullable: false, blank: false, maxSize: 66
		nric nullable: false, blank: false, maxSize: 9, minSize: 9
		gender nullable: true, inList:["M", "F"]
    }
	
	def beforeInsert() {
		dateCreated = new Date()
	}
}
